Rails : can't write unknown attribute `url'
        Posted  
        
            by 
                user2954789
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user2954789
        
        
        
        Published on 2013-11-05T03:39:17Z
        Indexed on 
            2013/11/05
            3:53 UTC
        
        
        Read the original article
        Hit count: 264
        
I am new to ruby on rails,and I am learning by creating a blog. I am not able to save to my blogs table and I get this error "can't write unknown attribute url"
Blogs migration :db/migrate/
class CreateBlogs < ActiveRecord::Migration 
  --def change 
   --- create_table :blogs do |t|
   ----   t.string :title
   ----  t.text :description
   ----   t.string :slug
   ---- t.timestamps
   --- end
  --end
end
Blogs Model :/app/models/blogs.rb 
class Blogs < ActiveRecord::Base
  --acts_as_url :title
  --def to_param
    ---url
  --end
  --validates :title, presence:true
end
Blogs Controller : /app/controllers/blogs_controller.rb
class BlogsController < ApplicationController
before_action :require_login--def new
--- @blogs = Blogs.new
--end--def show
---@blogs = Blogs.find(params[:id])
--end--def create
---@blogs = Blogs.new(blogs_params)
--if @blogs.save
---flash[:success] = "Your Blog has been created."
---redirect_to home_path
--else
---render 'new'
--end
-end--def blogs_params
---params.require(:blogs).permit(:title,:description)
--endprivate
--def require_login
---unless signed_in?
----flash[:error] = "You must be logged in to create a new Blog"
----redirect_to signin_path
---end
--end
end
Blogs Form:/app/views/blogs/new.html.erb
Blockquote
<%= form_for @blogs, url: blogs_path do |f| %><br/>
<%= render 'shared/error_messages_blogs' %><br/>
<%= f.label :title %><br/>
<%= f.text_field :title %><br/>
<%= f.label :description %><br/>
<%= f.text_area :description %><br/>
<%= f.submit "Submit Blog", class: "btn btn-large btn-primary" %><br/>
<% end %><br/>
and I have also added "resources :blogs" to my routes.rb file.
I get this error in controller at
if @blogs.save
© Stack Overflow or respective owner